<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page isELIgnored="false" %>
<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>李宁体育管理系统</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	 <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
	 <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
	 <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
     <link href="css/animate.min.css" rel="stylesheet">
     <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
      <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="css/plugins/clockpicker/clockpicker.css" rel="stylesheet">  
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet"> 
  </head>
  <body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>订单扫码评价</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form role="form" id="queryForm" class="form-inline">
                        <div class="form-group">
                            <input class="form-control" type="text" style="width:150px;" id="name" name="name"
                                   value="${map.name}" placeholder="姓名"/>
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" style="width:150px;" id="mobile" name="mobile"
                                   value="${map.mobile}" placeholder="手机号"/>
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" style="width:150px;" id="orderNo" name="orderNo"
                                   value="${map.orderNo}" placeholder="订单号"/>
                        </div>
                        
                       <div class="form-group">
	                     <input id="startTime" name="startTime" class="form-control" type="text" value="${map.startTime}" readonly placeholder="评价开始时间">
	                    </div>
	                        
	                    <div class="form-group" >
	                     <input id="endTime" name="endTime" class="form-control" type="text" value="${map.endTime}" readonly placeholder="评价结束时间">
	                    </div>
                        <div class="input-group">
                            <button class="btn btn-primary" type="button" style="margin-bottom: 0px;"
                                    onclick="search();"><i class="fa fa-search"></i>&nbsp;查询
                            </button>
                        </div>
                        <div class="input-group">
                            <button class="btn btn-primary" type="button" style="margin-bottom: 0px;"
                                    onclick="searchExecl();"><i class="fa fa-search"></i>&nbsp;导出
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- Panel Other -->
    <div class="ibox float-e-margins" id="tableShow">
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!-- Example Events -->
                    <div class="example-wrap">
                        <table id="ChannelProductListTable" data-mobile-responsive="true"
                               data-click-to-select="true" data-unique-id="id">
                            <thead>
                            </thead>
                        </table>
                    </div>
                </div>
                <!-- End Example Events -->
            </div>
        </div>
    </div>
    <div style="display: none;position: relative;
    top: -50px;" class="modal" id="myModal" tabindex="-1"role="dialog" aria-labelledby="myModalLable" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModallabel">消息提示</h4>
            </div>
            <div class="modal-body">
                <span id="deletecontent"></span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="confirm" onclick="confirm()">确定删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" id="cancel" onclick="cancel()">取消删除</button>

            </div>
        </div>
    </div>
</div>
</div>


<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/content.min.js?v=1.0.0"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<!--时间选择-->
<script src="js/plugins/layer/laydate/laydate.js"></script>
<!--下拉框-->
<script src="js/plugins/chosen/chosen.jquery.js"></script>
<script src="js/plugins/bootstrap-table/tableExport.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-table/1.11.1/extensions/export/bootstrap-table-export.min.js"></script>
<script>
    var $table = $('#ChannelProductListTable');

    var search = function () {
        $table.bootstrapTable('refresh');
    }
    var config = {
        ".chosen-select": {},
        ".chosen-select-deselect": {allow_single_deselect: !0},
        ".chosen-select-no-single": {disable_search_threshold: 10},
        ".chosen-select-no-results": {no_results_text: "Oops, nothing found!"},
        ".chosen-select-width": {width: "95%"}
    };

    $(document).ready(function () {
        //将表单元素和table属性转成json
        queryParams = function (params) {
            var temp = {};
            temp.currentResult = params.offset;
            temp.showCount = params.limit;
            var formParam = $('#queryForm').serializeArray();
            for (var i = 0; i < formParam.length; i++) {
                if (formParam[i].value != '') {
                    temp[formParam[i].name] = formParam[i].value;
                }
            }
            return temp;
        };


        detailFormatter = function (index, row) {
            var html = [];
            if (row.name) {
                html.push('<p><b>姓名:</b> ' + row.name + '</p>');
            }
            if (row.mobile) {
                html.push('<p><b>手机:</b> ' + row.mobile + '</p>');
            }
            if (row.orderNo) {
                html.push('<p><b>订单编号:</b> ' + row.orderNo + '</p>');
            }
            if (row.storeCode) {
                html.push('<p><b>店铺编号:</b> ' + row.storeCode + '</p>');
            }
            if (row.nickName) {
                html.push('<p><b>公众号:</b> ' + row.nickName + '</p>');
            }
            if (row.storeHealth) {
                html.push('<p><b>店铺卫生:</b> ' + row.storeHealth + '</p>');
            }
            if (row.prodCharacter) {
                html.push('<p><b>产品特点:</b> ' + row.prodCharacter + '</p>');
            }
            if (row.prodComfort) {
                html.push('<p><b>产品舒适度:</b> ' + row.prodComfort + '</p>');
            }
            if (row.message) {
                html.push('<p><b>消息:</b> ' + row.message + '</p>');
            }
            return html.join('');
        } 

        rowStyle = function (row, index) {
            var classes = ['active', 'success', 'info', 'warning', 'danger'];
            if (index % 2 === 0 && index / 2 < classes.length) {
                return {
                    classes: classes[index / 2]
                };
            }
            return {};
        }

        $table.bootstrapTable({
            url: "order/getOrderEvaluateList",
            pagination: !0,
            showRefresh: !0,
            showToggle: !0,
            showColumns: !0,
            iconSize: "outline",
            striped: true, //是否显示行间隔色
            queryParams: queryParams,//传递参数（*）
            sidePagination: "server", //服务端处理分页
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [5, 10, 20, 50,1000],        //可供选择的每页的行数（*）
            minimunCountColumns: 2,      //可供选择的每页的行数（*）
            //detailView: true,
            sortName: undefined,
            //exportDataType:'All', 
            sortOrder: 'asc',
            sortStable: false,
            type: "post",
            contentType: "application/json; charset=utf-8",
            detailFormatter: detailFormatter,
            rowStyle: rowStyle,
            iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
            icons: {
                refresh: "glyphicon-repeat",
                toggle: "glyphicon-list-alt",
                columns: "glyphicon-list",
                detailOpen: 'glyphicon-plus icon-plus',
                detailClose: 'glyphicon-minus icon-minus',
                sortable: 'glyphicon-minus icon-minus',
                //export:'glyphicon-export icon-share', 
            },
            onLoadSuccess: function (data) {
                if (data.total < 5) {
                    $table.bootstrapTable('getOptions')["height"] = 400;
                } else {
                    $table.bootstrapTable('getOptions')["height"] = 800;
                }

                $table.bootstrapTable('hideColumn', 'id');
                $table.bootstrapTable('hideColumn', 'remark');
            },
            showExport: true,  //是否显示导出按钮  
            buttonsAlign:"right",  //按钮位置  
            exportTypes:['csv', 'tsv', 'txt', 'sql', 'json', 'xml', 'doc'],  //导出文件类型  
            exportOptions:{  
                ignoreColumn: [1,2,12],  //忽略某一列的索引  
                fileName: '订单评价',  //文件名称设置  
                worksheetName: 'sheet1',  //表格工作区名称  
                tableName: '订单评价',  
                excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],  
                onMsoNumberFormat: DoOnMsoNumberFormat  
            },  
            columns: [
                {
                    title: 'id',
                    field: 'id',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '订单号',
                    field: 'orderNo',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '姓名',
                    field: 'name',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '手机',
                    field: 'mobile',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '店铺编号',
                    field: 'storeCode',
                    align: 'center',
                    valign: 'middle',
                },
                {
                    title: '公众号',
                    field: 'nickName',
                    align: 'center',
                    valign: 'middle',
                },
                {
                    title: '店铺卫生',
                    field: 'storeHealth',
                    align: 'center',
                    valign: 'middle',
                },
                {
                    title: '产品特点',
                    field: 'prodCharacter',
                    align: 'center',
                    valign: 'middle',
                },
                {
                    title: '产品舒适度',
                    field: 'prodComfort',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '是否想再次购买',
                    field: 'isBuyproduct',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                    	if(0==value){
                    		return "否"
                    	}else{
                    		return "是"
                    	}
                    }
                },
                {
                    title: '是否想再次光临',
                    field: 'isComeback',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                    	if(0==value){
                    		return "否"
                    	}else{
                    		return "是"
                    	}
                    }
                },
                {
                    title: '消息',
                    field: 'message',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '运营者备注',
                    field: 'remark',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '评价时间',
                    field: 'createdTime',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return CovertToDate(value);
                    }

                },
                {
                    title: '详情',
                    field: 'operate',
                    align: 'center',
                    width : '140',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                          return       '<button type="button" onclick="showDetail(\''+row.id+'\')"  class="btn btn-w-m btn-primary">查看详情</button>';

                    }
                } 
            ]
        });
        for (var selector in config)$(selector).chosen(config[selector]);
    });

    function tableHeight() {
        return $(window).height() - 50;
    }


    var showDetail=function(a){
    	var row = $table.bootstrapTable('getRowByUniqueId', a);
	    var b=JSON.stringify(row);
    	window.location.href="<%=basePath%>order/showOrderEvaluateDetail.do?id="+a;
 	<%-- 	jQuery.ajax({
			type: "post",
		    url: "<%=basePath%>order/showOrderEvaluateDetail",
		    dateType: "json",
		    data: {"custOrderEvaluate":b},
		    success: function (data) {
		    	if(data.status==400){
		    		
		    	}else{
		    		
		    	}
		    },
		});	 --%>
    }
    
	var start = {
			elem : "#startTime",
			format : "YYYY-MM-DD",
			//min : laydate.now(),
			max : "2099-06-16",
			istime : true,
			istoday : false,
			choose : function(datas) {
				end.min = datas;
				end.start = datas
			}
		};
		var end = {
			elem : "#endTime",
			format : "YYYY-MM-DD",
			min : start,
			max : "2099-06-16",
			istime : true,
			istoday : false,
			choose : function(datas) {
				start.max = datas
			}
		};
		laydate(start);
		laydate(end);
    
    function DoOnMsoNumberFormat(cell, row, col) {  
        var result = "";  
        if (row > 0 && col == 0)  
            result = "\\@";  
        return result;  
    }
    function CovertToDate(unittime) {
        //3.转换成js时间格式
        var jsDate = new Date(unittime).Format("yyyy-MM-dd hh:mm:ss");
     	
        return jsDate;


    }
    Date.prototype.Format = function (fmt) { //author: meizz 
        var o = {
            "M+": this.getMonth() + 1, //月份 
            "d+": this.getDate(), //日 
            "h+": this.getHours(), //小时 
            "m+": this.getMinutes(), //分 
            "s+": this.getSeconds(), //秒 
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
            "S": this.getMilliseconds() //毫秒 
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
    var searchExecl = function() {
    	var name = $("#name").val();    	
    	var mobile = $("#mobile").val();
    	var orderNo = $("#orderNo").val();
    	var startTime = $("#startTime").val();
    	var endTime = $("#endTime").val();
    	window.location.href = "order/exportOrderEvaluate?name="+name+"&mobile="+mobile+"&orderNo="+orderNo+"&startTime="+startTime+"&endTime="+endTime; 
    }
</script>
  </body>
</html>
